@isTest
private class ContractSyncUtilTest {
    static testMethod void testMethod1() {
        

        //创建经理
        Id ldcProfile = [Select Id From Profile Where Name ='系统管理员' or Name='System Administrator'].Id;
       
     



                     
        Account a = TestUtils.createAccount();
        a.Level__c = '一级医院';
        a.AccountNumber = '01';
      

        a.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('Dealer', 'Account');
        insert a;
         ProductStructure__c ps = new ProductStructure__c();
        ps.Classify3__c = '试剂';
         insert ps;

         //业务机会1
        Opportunity opp = TestUtils.createOpportunity();
        opp.AccountId = a.Id;
        insert opp;


       
        //创建合同
        Contract__c c = new Contract__c();
        c.Corpcode__c = 'MKSY';
        c.Status__c = '草稿';
        c.Vsalestrucode__c = '05';
        //c.Maccura__c = a.Id;
        c.Account__c = a.Id;
        c.Opportunity__c  = opp.Id;
        c.ApproveType__c = '0';
        c.ContractSource__c = '0';
        //c.CooperationType__c = '0';
        c.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('TerminalContract', 'Contract__c');



        insert c ;
        //创建产品
        Product__c p = new Product__c();
        p.NCCode__c = '11111';
         p.ProductStructure__c = ps.Id;
         p.RecordTypeId = Utils.getRecordTypeIdByDevNameAndObjName('NCProduct', 'Product__c');

        insert p;


          //报价2
        Quote qt2 = new Quote(Name = '试剂报价',Type__c = '试剂报价',OpportunityId = opp.Id,IsActive__c = true);
        qt2.Status = '已批准';
        qt2.Contract__c = c.Id;
        insert qt2 ;

        QuoteProduct__c qp = new QuoteProduct__c(Name = '测试报价产品2',Product__c = p.Id,Quote__c = qt2.Id,SalesPrice__c = 5);
        insert qp ;
       
        //创建合同产品
        ContractProduct__c cp = new ContractProduct__c();
        cp.Contract__c = c.Id;
        cp.SalesPrice__c = 10.0;
        cp.Product__c = p.Id;
        cp.Only__c = 'cp2';
    	insert cp ;
       // cp.Number__c = 10;
        System.debug('发送OA');
        ContractSyncUtil.postToOA(c.Id);

        ContractSyncUtil.unTieContract(c.Id);
    }
}